package com.hsurosy.domain.award.model.aggregate;

import com.hsurosy.domain.award.model.entity.UserAwardRecordEntity;
import com.hsurosy.domain.award.model.entity.UserCreditAwardEntity;
import com.hsurosy.domain.award.model.valobj.AwardStateVO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * @Author Hsu琛君珩
 * @Date 2024-11-24 15:25
 * @Description 发放奖品聚合对象
 * @Version: v1.0.0
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class GiveOutPrizesAggregate {

    /** 用户ID */
    private String userId;
    /** 用户中奖记录实体 */
    private UserAwardRecordEntity userAwardRecordEntity;
    /** 用户积分奖品实体 */
    private UserCreditAwardEntity userCreditAwardEntity;

    /**
     * 构建用户中奖记录实体
     *
     * @param userId 用户ID
     * @param orderId 订单ID
     * @param awardId 奖品ID
     * @param awardState 奖品状态
     * @return 构建好的用户中奖记录实体对象
     */
    public static UserAwardRecordEntity buildDistributeUserAwardRecordEntity(String userId, String orderId, Integer awardId, AwardStateVO awardState) {
        UserAwardRecordEntity userAwardRecord = new UserAwardRecordEntity();
        userAwardRecord.setUserId(userId);
        userAwardRecord.setOrderId(orderId);
        userAwardRecord.setAwardId(awardId);
        userAwardRecord.setAwardState(awardState);
        return userAwardRecord;
    }

    /**
     * 构建用户积分奖品实体
     *
     * @param userId 用户ID
     * @param creditAmount 积分金额
     * @return 构建好的用户积分奖品实体对象
     */
    public static UserCreditAwardEntity buildUserCreditAwardEntity(String userId, BigDecimal creditAmount) {
        return UserCreditAwardEntity.builder()
                .userId(userId)
                .creditAmount(creditAmount)
                .build();
    }

}
